package com.app.controller;


import cn.dev33.satoken.stp.StpUtil;
import com.app.mapper.UserMapper;
import com.app.pojo.PublicAnnouncement;
import com.app.pojo.User;
import com.app.service.IPublicAnnouncementService;
import com.app.service.IUserService;
import com.app.util.Result;
import com.app.vo.PaymentRecordsLogVo;
import com.app.vo.PublicAnnouncementVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 信息公告 前端控制器
 * </p>
 *
 * @author yoominic
 * @since 2024-07-29
 */
@Api(tags = "信息公告相关接口")
@RestController
@RequestMapping("/publicAnnouncement")
public class PublicAnnouncementController {

    @Autowired
    private IPublicAnnouncementService paymentRecordsLogService;
    @Autowired
    private UserMapper userMapper;


    @ApiOperation(value = "分页查询信息公告以及通知")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "当前页码", required = true, dataType = "Integer"),
            @ApiImplicitParam(name = "limit", value = "每页条数", required = true, dataType = "Integer"),
            @ApiImplicitParam(name = "type", value = "类型  1公告  2通知", required = false, dataType = "String")
    })
    @GetMapping("/getPublicAnnouncementList")
    public Result getPublicAnnouncementList(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                                @RequestParam(value = "limit", defaultValue = "10") Integer limit,
                                                @RequestParam(value = "type" ,required = false) String type) {
        PublicAnnouncementVo vo = paymentRecordsLogService.getPublicAnnouncementList( page, limit, type);
        return Result.success(vo);
    }

    @ApiOperation(value = "根据id查询信息公告以及通知")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "公告id", required = true)
    })
    @PostMapping("/getPublicAnnouncementById")
    public Result getPublicAnnouncementById(@RequestBody PublicAnnouncement publicAnnouncement) {
        PublicAnnouncement publicAnnouncement1 = paymentRecordsLogService.getPublicAnnouncementById(publicAnnouncement.getId());
        return Result.success(publicAnnouncement1);
    }


}

